"use strict";
/* Controllers */
app.controller("grafanaDapanController", ['$scope', '$location', '$rootScope', '$routeParams', 'grafanaDapanService', function ($scope, $location, $rootScope, $routeParams, grafanaDapanService) {

    var vm = $scope.vm = {};

    vm.p = {};
    vm.result = {};
    vm.p.id = $routeParams.id; //
    vm.p.url = '';
    vm.itemName = '默认名称看板';

    $scope.loadUrl = function (id) {
        var vm = $scope.vm;
        var idxUrl = function(id) {
            if (id == null) {
                return "-";
            }
            var location = "http://grafana-zp.58corp.com/";
            var params = "&from=now-24h&to=now&refresh=1m&theme=light&kiosk";
            var params2 = "&from=now-45d&to=now&refresh=1m&theme=light&kiosk";
            var url = '-';
            switch (id) {
                case "0":
                    vm.itemName = '资源队列看板';
                    url = '/d/lE7ASunnk/zi-yuan-dui-lie-kan-ban?orgId=1' + params;
                    break;
                case "1":
                    vm.itemName = '资源队列看板';
                    url = '/d/lE7ASunnk/zi-yuan-dui-lie-kan-ban?orgId=1' + params;
                    break;
                case "2":
                    vm.itemName = '无线流量看板';
                    url = "/d/QYStQkSnz/wu-xian-liu-liang-da-pan?orgId=1" + params;
                    break;
                case "3":
                    vm.itemName = 'HRG指标看板';
                    url = "/d/CujVPwn7k/hrgzhi-biao-kan-ban?orgId=1" + params2;
                    break;
                case "4":
                    return "http://yunchuang.58corp.com/visualization/shares/ab64b81b9077876ccb57b86e0861b0be529fea91";
                case "5":
                    return "https://wuba.xinghuo.58.com/visualization/share/5555?access=sso&api_params=%7B%22appid%22%3A211%2C%22appsign%22%3A%228bc862ea9514931e489efb6dc268dc0d%22%7D&filter_params=%7B%7D&dataset_params=%5B%5D";
                case "6":
                    vm.itemName = '实时指标看板';
                    url = "/d/UiFuKKWnz/shi-shi-zhi-biao-kan-ban-v1-0?orgId=1" + params;
                    break;
                case "7":
                    vm.itemName = '实时流量看板';
                    url = "/d/QYStQkSnz/wu-xian-liu-liang-da-pan?orgId=1" + params;
                    break;
                case "8":
                    vm.itemName = '实时延时看板';
                    url = "/d/rIl9_1Bnz/shi-shi-yan-shi-kan-ban?orgId=1" + params;
                    break;
                default:
                    break;
            }
            return location + url;
        };
        vm.p.url = idxUrl(id);
        console.log(vm.p.url);
    };

    $scope.loadUrl(vm.p.id);
}]);


/* Services */
app.service('grafanaDapanService', ['ajaxService', function (ajaxService) {

}]);


